<template>
    <div class="received_page received_page_v2" :style="main_back_obj">
        <div class="main_wrap">
            <div class="top_wrap" v-if="is_ok=='ok'">
                <img :src="success_icon">
                <p>恭喜您领取成功</p>
            </div>
            <div class="top_wrap" v-if="is_ok=='sorry'">
                <img :src="sorry_icon">
                <p>礼物被领光了</p>
            </div>
            <div class="gift_wrap" :style="{'background-image': 'url(' +gift_back_img+')'}">
                <img :src=" current_host + wx_img_url + mall_qrcode">
            </div>
            <div class="word_wrap">
                <p>
                    扫码关注二维码后查看其他商品
                </p>
            </div>
            <div class="logo_wrap_v2">
                <div class="logo_wrap_main">
                    <img :src="logo_img">
                    <p>替您精挑细选 足不出户 自在购享</p>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import api from '@/api/api'
export default {
    name: 'giftReceived',
    data() {
        return {
            mall_qrcode: 'http://mmbiz.qpic.cn/mmbiz/R4u1KHHbhPd1zgbF1TxIBCfZ5ccv82s0xIUl4ib9ia6IBibUpOWgjGdbhZ5g9zdB9OzNib7lxB3zvWurpq41bNJdQw/0',
            order_data: {},
            is_ok: this.$route.query.is_ok,
            success_icon: require('assets/images/ok.png'),
            sorry_icon: require('assets/images/gantanhao.png'),
            sorry_img: require('assets/images/kong.png'),

            logo_img: require('assets/images/logo.png'),

            gift_back_img: require('assets/images/liwu_tupian.png'),
            share_main_bg: require('assets/images/share_main.png'),
            windowHeight: document.body.scrollHeight,
            main_back_obj: {
                'background-size': '100% ' + document.body.scrollHeight +'px'
            }
        }
    },
    methods: {
        postStepChange: function (val) {
            var _self = this;
            _self.now_step += 1;
            _self.step_list[val + 1].is_active = true;
        },
        goToMarket: function () {
            let market_url = this.current_host + '/mp/market/detail/' + this.order_data.resource_id;
            window.location.replace(market_url);
        },

        goToMarketList: function () {
            let market_url = this.current_host + '/mp/home';
            window.location.replace(market_url);
        },
        getOrderInfo: function () {
            let order_params = {
                functioncode: 'give_gifts_info',
                gift_id: this.$route.params.gift_id
            }
            api.get(order_params).then((res) => {
                if (res.data.returncode == '000000') {
                    this.getMpInfo();
                    this.order_data = res.data.record;
                }
            });
        },
        getMpInfo: function () {
            let params = {
                team_id: this.team_id,
                show_authorized: "yes",
                functioncode: 'mp_query'
            };
            let _self = this;
            api.get(params).then((res) => {
                if (res.data.returncode == '000000') {
                    if (res.data.record.length > 0) {
                        let mp_list = res.data.record;
                        for (let temp of mp_list) {
                            if (temp.id == _self.mp_id) {
                                _self.mall_qrcode = temp.wx_qrcode_url;
                            }
                        }
                    }
                }
            });
        }
    },
    mounted: function () {
        this.$nextTick(function () {
            this.windowHeight = document.body.scrollHeight;
            this.main_back_obj = {
                'background-size': '100% ' + document.body.scrollHeight +'px',
            };
            this.getOrderInfo();
        });
    }
}
</script>


